# -*- coding: utf-8 -*-
# @Time : 2022/4/9 23:28
# @Author : Liuqing
# @File : 31_对字典列表排序.py
# @Software : PyCharm
dict1 = [
    {"name": "James", "num": 25},
    {"name": "Alice", "num": 39},
    {"name": "Hoton", "num": 35},
]

# 方法一，利用sort()
dict1.sort(key=lambda item: item["num"])
print(dict1)

# 方法二，利用sorted()
print(sorted(dict1, key=lambda item: item["num"]))
